package org.stvd.entities.common;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;
import org.stvd.core.annotation.serializer.DateTimeSerializer;
import org.stvd.entities.base.BaseEntity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 临时验证-实体类
 * @author houzx
 */
@Entity
@Table(name="verify_tmp")
@IdClass(VerifyTmpPK.class)
public class VerifyTmp extends BaseEntity{

    private static final long serialVersionUID = 5239457177784152194L;
    
    /**
     * 需要验证的邮箱或手机号
     */
    @Id
    @Column(name="verify_id")
    private String verifyId = "";
    
    /**
     * 验证码用途：00-注册；01-绑定；02-重置密码；
     */
    @Id
    @Column(name="use_for")
    private String useFor = "";
    
    /**
     * 手机验证码或邮箱验证信息
     */
    @Column(name="verify_code")
    private String verifyCode = "";
    
    /**
     * 验证有效期的起始计算时间
     */
    @Column(name="input_datetime")
    @DateTimeFormat(pattern= "yyyy-MM-d HH:mm:ss")
    @JsonSerialize(using = DateTimeSerializer.class)
    private Date inputDatetime = null ;
    
    public VerifyTmp() {}
    /**
     * 验证信息临时表构造方法
     * @param verifyId 需要验证的邮箱或手机号
     * @param useFor 手机验证码或邮箱验证信息
     * @param verifyCode 验证码用途：00-账号注册；01-账号绑定；02-找回密码；
     * @param inputDatetime 验证有效期的起始计算时间
     */
    public VerifyTmp(String verifyId, String useFor, String verifyCode, Date inputDatetime) {
        this.verifyId = verifyId;
        this.useFor = useFor;
        this.verifyCode = verifyCode;
        this.inputDatetime = inputDatetime;
    }
    public String getVerifyId() {
        return verifyId;
    }
    public void setVerifyId(String verifyId) {
        this.verifyId = verifyId;
    }
    public String getUseFor() {
        return useFor;
    }
    public void setUseFor(String useFor) {
        this.useFor = useFor;
    }
    public String getVerifyCode() {
        return verifyCode;
    }
    public void setVerifyCode(String verifyCode) {
        this.verifyCode = verifyCode;
    }
    public Date getInputDatetime() {
        return inputDatetime;
    }
    public void setInputDatetime(Date inputDatetime) {
        this.inputDatetime = inputDatetime;
    }
}
